
//
//  NoticeWarnTableViewCell.m
//  Rail
//
//  Created by hychen on 2018/2/28.
//  Copyright © 2018年 Hychen. All rights reserved.
//

#import "NoticeWarnTableViewCell.h"

@interface NoticeWarnTableViewCell ()
@property (weak, nonatomic) IBOutlet UILabel *typeLabel;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *authorLabel;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;
@property (weak, nonatomic) IBOutlet UIImageView *unreadImage;

@end
@implementation NoticeWarnTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    [self showBottomLineWithPaddingX:15 color:nil];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setModel:(NoticeWarnModel *)model {
    _model = model;
    self.titleLabel.text = model.title;
    self.authorLabel.text = model.publisher;
    self.timeLabel.text = [BMUtils chineseMMDDHHmmWithServiceTime:model.publish_time];
    self.unreadImage.hidden = model.read;
    
    NSDate *publishDate = [[model.publish_time substringToIndex:19] YJ_dateWithYYYYMMDDHHmmsss];
    if ([publishDate distanceInDaysToDate:[NSDate date]] <= 7) {
        NSMutableSet *newCacheSet = [[CacheTool sharedTool] objectForKey:Cache_Notice_Scan_Key];
        self.unreadImage.hidden = [newCacheSet containsObject:model.noticeid];
    }
    else {
        self.unreadImage.hidden = YES;
    }
}

@end
